<template>
  <div>
    <!--1.视图-->
    <el-table  ref="singleTable" highlight-current-row @current-change="handleCurrentChange"  :data="driverList">
      <el-table-column type="index" width="50"/>
      <el-table-column label="质检人编号"  width="100px" align="center" prop="userId" />
      <el-table-column label="质检人名称"  width="100px" align="center" prop="userName" />
      <el-table-column label="用户昵称" align="center" prop="nickName"/>
      <el-table-column label="手机号码" align="center" prop="phonenumber"/>
      <el-table-column label="状态" align="center" prop="status">
        <template slot-scope="scope">
          <el-switch
            v-model="scope.row.status"
            active-value="0"
            inactive-value="1"
          ></el-switch>
        </template>
      </el-table-column>
      <el-table-column label="创建时间" align="center" prop="createTime" width="160">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <div style="margin-top: 20px">
      <el-button type="primary" @click="addCheckByUser">确 定</el-button>
      <el-button @click="setCurrent()">取消选择</el-button>
    </div>
  </div>
</template>

<script>
import cropIng from "@/store/modules/cropIng";
import {getDriverList} from "@/api/crop/products";

export default {
  name: "ToDrive",
  data() {
    return {
      //2.属性定义
      driverList:[],
      currentRow: null,
      isTableVisible: true,
    }
  }, methods: {
    //3.方法
    setCurrent(row) {
      this.$refs.singleTable.setCurrentRow(row);
    },
    handleCurrentChange(val) {
      this.currentRow = val;
      cropIng.state.driverId=this.currentRow.userId;
      cropIng.state.driverName=this.currentRow.userName;
      console.log(cropIng)
    },
    addCheckByUser(){
      console.log(cropIng.state.driverId,"成羽欣1")
      console.log(cropIng.state.driverName,"成羽欣1")
      this.$emit('close'); // 发送 'close' 事件到父组件
    },
    getDriver(){
      getDriverList().then(res =>{
        this.driverList = res.data;
      })
    },
  }, created() {
    //4.钩子函数
    this.getDriver();
  }
}
</script>

<style scoped>

</style>
